package com.bwie.controller;

import com.bwie.pojo.Result;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

import java.io.File;
import java.io.IOException;
import java.util.Date;

/**
 * @
 * @descriptions: Upload
 * @author: LiYang
 * @date: 2025/3/18 15:38
 * @version: 1.0
 */
@Controller
@RequestMapping("upload")
public class Upload {
    private final static String upload="D:\\IdeaProjects\\month\\month_service\\src\\main\\webapp\\upload\\";
    @RequestMapping("img")
    @ResponseBody
    public Result img(@RequestParam("file") MultipartFile file) throws IOException {
        String s = new Date().getTime() + file.getOriginalFilename();
        File file1 = new File(upload + s);
        file.transferTo(file1);
        return Result.success("上传成功","/upload/");
    }
}
